/**
 * 启动全屏
 * launchFullScreen(document.documentElement); // 整个网页
 */
export const launchFullScreen = (element: HTMLElement | any) => {
    if (element.requestFullscreen) {
        element.requestFullscreen();
    } else if (element.mozRequestFullScreen) {
        element.mozRequestFullScreen();
    } else if (element.webkitRequestFullscreen) {
        element.webkitRequestFullscreen();
    } else if (element.msRequestFullscreen) {
        element.msRequestFullscreen();
    }
}

/**
 * 退出全屏
 */
export const exitFullscreen = () => {
    const doc: any = document
    if (doc.exitFullscreen) {
        doc.exitFullscreen();
    } else if (doc.mozCancelFullScreen) {
        doc.mozCancelFullScreen();
    } else if (doc.webkitExitFullscreen) {
        doc.webkitExitFullscreen();
    } else if (doc.msExitFullscreen) {
        doc.msExitFullscreen();
    }
}

/**
 * 是否全屏
 */
export const isFullScreen = () => {
    return Math.abs(window.screen.height - window.document.documentElement.clientHeight) <= 17
}

/* 判断窗口是否全屏做些事，比如切换全屏icon */
window.onresize = function() {
	if(isFullScreen){
		// do something
	}else{
		// do something
	}
}